package com.example.shouybl.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.ArrayList;

/**
 * Created by Administrator on 2015/10/16.
 */
public class VpiPageAdapter extends FragmentPagerAdapter {
    private ArrayList<Fragment> fragments;
    private String[] title;
    public VpiPageAdapter(FragmentManager fm,ArrayList<Fragment> fragments,String[] title) {
        super(fm);
        this.fragments=fragments;
        this.title=title;
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments==null?0:fragments.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return title==null?super.getPageTitle(position):title[position];
    }
}
